diff options
Diffstat (limited to 'httemplate/elements')
| -rw-r--r-- | httemplate/elements/ckeditor/plugins/blockprotect/plugin.js | 139 | ||||
| -rw-r--r-- | httemplate/elements/make_appointment.html | 39 | ||||
| -rw-r--r-- | httemplate/elements/popup_link-make_appointment.html | 2 | ||||
| -rw-r--r-- | httemplate/elements/schedule-appointment.html | 21 |
4 files changed, 140 insertions, 61 deletions
diff --git a/httemplate/elements/ckeditor/plugins/blockprotect/plugin.js b/httemplate/elements/ckeditor/plugins/blockprotect/plugin.js new file mode 100644 index 000000000..e4ef39167 --- /dev/null +++ b/httemplate/elements/ckeditor/plugins/blockprotect/plugin.js @@ -0,0 +1,139 @@ +/** + * The "blockprotect" plugin. Adapted from the "placeholder" plugin. + */ + +(function() { + var delim_o = '{'; + var delim_c = '}'; + + var create_block = function(content, inside) { + if (inside) return content; + // fix nbsp's + content = content.replace(/ /gi, ' '); + // escape the content + var el = document.createElement('SPAN'); + // IE8 compat + if( typeof(el.textContent) != 'undefined' ) { + el.textContent = content; + } else if( typeof(el.innerText) != 'undefined' ) { + el.innerText = content; + } + el.setAttribute('class', 'cke_blockprotect'); + return el.outerHTML; + }; + var block_writeHtml = function( element ) { + // to unescape the element contents, write it out as HTML, + // stick that into a SPAN element, and then extract the text + // content of that. + var inner_writer = new CKEDITOR.htmlParser.basicWriter; + element.writeChildrenHtml(inner_writer); + + var el = document.createElement('SPAN'); + el.innerHTML = inner_writer.getHtml(); + if( typeof(el.textContent) != 'undefined' ) { + return el.textContent; + } else if( typeof(el.innerText) != 'undefined' ) { + return el.innerText; + } + }; + var to_protected_html = function(data) { + var depth = 0; + var chunk = ''; + var out = ''; + var in_tag = false; + var p = 0; // position in the string + while( 1 ) { + // find the next delimiter of either kind + var i = data.indexOf(delim_o, p); + var j = data.indexOf(delim_c, p); + if (i == -1 && j == -1) { + // then there are no more delimiters + break; + } else if ((i < j || j == -1) && i != -1) { + // next delimiter is an open + // push everything from current position to + // the delimiter + if ( i > p ) chunk += data.substr(p, i - p); + p = i + 1; + if ( depth == 0 ) { + // we're in document text. find whether an HTML tag starts, + // or ends, before the next delimiter, so that we know whether + // to output the next block in a SPAN or just as escaped text + for(var q = 0; q < chunk.length; q++ ) { + if (chunk[q] == '<') in_tag = true; + if (chunk[q] == '>') in_tag = false; + } + + // then output the chunk, and go to the start of the + // protected block + out += chunk; + chunk = ''; + } + chunk += delim_o; + depth++; + } else if ((j < i || i == -1) && j != -1) { + // next delimiter is a close + if ( j > p ) chunk += data.substr(p, j - p); + p = j + 1; + depth--; + chunk += delim_c; + if ( depth == 0 ) { + // end of a protected block + out += create_block(chunk, in_tag); + chunk = ''; + } else if ( depth < 0 ) { + depth = 0; + } + } else { + // can't happen + } + } + // append any text after the last delimiter + if ( depth ) { + out += create_block(data.substr(p), in_tag); + } else { + out += data.substr(p); + } + return out; + }; + + CKEDITOR.plugins.add( 'blockprotect', { + afterInit: function( editor ) { + CKEDITOR.addCss( '.cke_blockprotect' + + '{' + + 'background-color: #ffff88;' + + ( CKEDITOR.env.gecko ? 'cursor: default;' : '' ) + + '}' + ); + + // keep these from getting stripped out + editor.filter.allow('span(cke_blockprotect)', + 'blockprotect', true); + + // add filter at the front of toHtml + editor.on( 'toHtml', + function( evt ) { + evt.data.dataValue = + to_protected_html(evt.data.dataValue); + return evt; + }, + this, null, 0 + ); + + editor.dataProcessor.htmlFilter.addRules({ + elements: { + span: function( element ) { + if ( element.className = 'cke_blockprotect' ) { + // defeat HTML escaping + var content = block_writeHtml(element); + element.writeHtml = function(writer, filter) { + writer.text(content); + } + } + } // span function + } // elements + }); + } + }); // plugins.add +}) (); + diff --git a/httemplate/elements/make_appointment.html b/httemplate/elements/make_appointment.html deleted file mode 100644 index ddf377f54..000000000 --- a/httemplate/elements/make_appointment.html +++ /dev/null @@ -1,39 +0,0 @@ -<& /elements/header-popup.html &> - -% #XXX actually, the action needs to repace the top-level window with this -% #$params->{'action'} = $p. 'rt/Search/Schedule.html?'. $query; -<FORM NAME="appointment_form" METHOD="POST" ACTION="<% $p %>elements/schedule-appointment.html"> - -<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cgi->param('custnum') |h %>"> - -% my @sched_item = qsearch('sched_item', { 'disabled' => '', }); -% my @username = map $_->access_user->username, @sched_item; -% foreach my $username (@username) { - <INPUT TYPE="hidden" NAME="username" VALUE="<% $username |h %>"> -% } - -Length: -<SELECT NAME="LengthMin"> -% for ( my $hours = .5; $hours < 10.5; $hours += .5 ) { -% my $min = $hours * 60; - <OPTION VALUE="<% $min %>" - <% $min == $default_length ? 'SELECTED' : '' %> - ><% $hours %> hour<% $hours > 1 ? 's' : '' %> -% } -</SELECT> -<BR> -<BR> - -<INPUT TYPE="submit" VALUE="Schedule appointment"> - -</FORM> - -<& /elements/footer-popup.html &> -<%init> - -my $default_length = FS::Conf->new->config('default_appointment_length') || 180; - -#XXX '&pkgnum=$pkgnum";need to be for specific package/location, not just for a customer... default to active(/ordered) package in a pkg_class w/ticketing_queueid, otherwise, a popup? (well, we're already a popup now) we're getting complicated like form-creat_ticket.html - - -</%init> diff --git a/httemplate/elements/popup_link-make_appointment.html b/httemplate/elements/popup_link-make_appointment.html index 60a337c04..3a8d37a8c 100644 --- a/httemplate/elements/popup_link-make_appointment.html +++ b/httemplate/elements/popup_link-make_appointment.html @@ -26,6 +26,6 @@ $params->{'actionlabel'} ||= 'Schedule appointment'; #$params->{'width'} ||= 350; #$params->{'height'} ||= 220; -$params->{'action'} = $p. '/elements/make_appointment.html?custnum='. $params->{'custnum'}; +$params->{'action'} = $p. 'misc/make_appointment.html?custnum='. $params->{'custnum'}; </%init> diff --git a/httemplate/elements/schedule-appointment.html b/httemplate/elements/schedule-appointment.html deleted file mode 100644 index 69b9f422b..000000000 --- a/httemplate/elements/schedule-appointment.html +++ /dev/null @@ -1,21 +0,0 @@ -<& /elements/header-popup.html &> -<h1>Scheduling appointment...</h1> -<SCRIPT TYPE="text/javascript"> - window.top.location.href = '<% $url %>'; -</SCRIPT> -<& /elements/footer-popup.html &> -<%init> - -my @username = map encode_entities($_), $cgi->param('username'); -my $LengthMin = encode_entities( $cgi->param('LengthMin') ); -my $custnum = encode_entities( $cgi->param('custnum') ); - -my $query = join('&', map "username=$_", @username). - "&LengthMin=$LengthMin". - "&custnum=$custnum". - "&RedirectToBasics=1"; - #XXX '&pkgnum=$pkgnum";need to be for specific package/location, not just for a customer... default to active(/ordered) package in a pkg_class w/ticketing_queueid, otherwise, a popup? we're getting complicated like form-creat_ticket.html - -my $url = $p. 'rt/Search/Schedule.html?'. $query; - -</%init> |
