Plugin Directory

Changeset 508925


Ignore:
Timestamp:
02/22/2012 05:01:46 PM (14 years ago)
Author:
jazzigor
Message:

Updating trunk to v0.9.4

Location:
jazzy-forms/trunk
Files:
13 added
16 edited

Legend:

Unmodified
Added
Removed
  • jazzy-forms/trunk/3rdparty/mustache.js

    r491567 r508925  
    55*/
    66
    7 var Mustache = function() {
    8   var Renderer = function() {};
     7var Mustache = function () {
     8  var _toString = Object.prototype.toString;
     9
     10  Array.isArray = Array.isArray || function (obj) {
     11    return _toString.call(obj) == "[object Array]";
     12  }
     13
     14  var _trim = String.prototype.trim, trim;
     15
     16  if (_trim) {
     17    trim = function (text) {
     18      return text == null ? "" : _trim.call(text);
     19    }
     20  } else {
     21    var trimLeft, trimRight;
     22
     23    // IE doesn't match non-breaking spaces with \s.
     24    if ((/\S/).test("\xA0")) {
     25      trimLeft = /^[\s\xA0]+/;
     26      trimRight = /[\s\xA0]+$/;
     27    } else {
     28      trimLeft = /^\s+/;
     29      trimRight = /\s+$/;
     30    }
     31
     32    trim = function (text) {
     33      return text == null ? "" :
     34        text.toString().replace(trimLeft, "").replace(trimRight, "");
     35    }
     36  }
     37
     38  var escapeMap = {
     39    "&": "&",
     40    "<": "&lt;",
     41    ">": "&gt;",
     42    '"': '&quot;',
     43    "'": '&#39;'
     44  };
     45
     46  function escapeHTML(string) {
     47    return String(string).replace(/&(?!\w+;)|[<>"']/g, function (s) {
     48      return escapeMap[s] || s;
     49    });
     50  }
     51
     52  var regexCache = {};
     53  var Renderer = function () {};
    954
    1055  Renderer.prototype = {
     
    1863    context: {},
    1964
    20     render: function(template, context, partials, in_recursion) {
     65    render: function (template, context, partials, in_recursion) {
    2166      // reset buffer & set context
    22       if(!in_recursion) {
     67      if (!in_recursion) {
    2368        this.context = context;
    2469        this.buffer = []; // TODO: make this non-lazy
     
    2671
    2772      // fail fast
    28       if(!this.includes("", template)) {
    29         if(in_recursion) {
     73      if (!this.includes("", template)) {
     74        if (in_recursion) {
    3075          return template;
    3176        } else {
     
    3580      }
    3681
     82      // get the pragmas together
    3783      template = this.render_pragmas(template);
     84
     85      // render the template
    3886      var html = this.render_section(template, context, partials);
    39       if(in_recursion) {
    40         return this.render_tags(html, context, partials, in_recursion);
    41       }
    42 
    43       this.render_tags(html, context, partials, in_recursion);
     87
     88      // render_section did not find any sections, we still need to render the tags
     89      if (html === false) {
     90        html = this.render_tags(template, context, partials, in_recursion);
     91      }
     92
     93      if (in_recursion) {
     94        return html;
     95      } else {
     96        this.sendLines(html);
     97      }
    4498    },
    4599
     
    47101      Sends parsed lines
    48102    */
    49     send: function(line) {
    50       if(line != "") {
     103    send: function (line) {
     104      if (line !== "") {
    51105        this.buffer.push(line);
    52106      }
    53107    },
    54108
     109    sendLines: function (text) {
     110      if (text) {
     111        var lines = text.split("\n");
     112        for (var i = 0; i < lines.length; i++) {
     113          this.send(lines[i]);
     114        }
     115      }
     116    },
     117
    55118    /*
    56119      Looks for %PRAGMAS
    57120    */
    58     render_pragmas: function(template) {
     121    render_pragmas: function (template) {
    59122      // no pragmas
    60       if(!this.includes("%", template)) {
     123      if (!this.includes("%", template)) {
    61124        return template;
    62125      }
    63126
    64127      var that = this;
    65       var regex = new RegExp(this.otag + "%([\\w-]+) ?([\\w]+=[\\w]+)?" +
    66             this.ctag);
    67       return template.replace(regex, function(match, pragma, options) {
    68         if(!that.pragmas_implemented[pragma]) {
    69           throw({message:
     128      var regex = this.getCachedRegex("render_pragmas", function (otag, ctag) {
     129        return new RegExp(otag + "%([\\w-]+) ?([\\w]+=[\\w]+)?" + ctag, "g");
     130      });
     131
     132      return template.replace(regex, function (match, pragma, options) {
     133        if (!that.pragmas_implemented[pragma]) {
     134          throw({message:
    70135            "This implementation of mustache doesn't understand the '" +
    71136            pragma + "' pragma"});
    72137        }
    73138        that.pragmas[pragma] = {};
    74         if(options) {
     139        if (options) {
    75140          var opts = options.split("=");
    76141          that.pragmas[pragma][opts[0]] = opts[1];
     
    84149      Tries to find a partial in the curent scope and render it
    85150    */
    86     render_partial: function(name, context, partials) {
    87       name = this.trim(name);
    88       if(!partials || partials[name] === undefined) {
     151    render_partial: function (name, context, partials) {
     152      name = trim(name);
     153      if (!partials || partials[name] === undefined) {
    89154        throw({message: "unknown_partial '" + name + "'"});
    90155      }
    91       if(typeof(context[name]) != "object") {
     156      if (!context || typeof context[name] != "object") {
    92157        return this.render(partials[name], context, partials, true);
    93158      }
     
    98163      Renders inverted (^) and normal (#) sections
    99164    */
    100     render_section: function(template, context, partials) {
    101       if(!this.includes("#", template) && !this.includes("^", template)) {
    102         return template;
     165    render_section: function (template, context, partials) {
     166      if (!this.includes("#", template) && !this.includes("^", template)) {
     167        // did not render anything, there were no sections
     168        return false;
    103169      }
    104170
    105171      var that = this;
    106       // CSW - Added "+?" so it finds the tighest bound, not the widest
    107       var regex = new RegExp(this.otag + "(\\^|\\#)\\s*(.+)\\s*" + this.ctag +
    108               "\n*([\\s\\S]+?)" + this.otag + "\\/\\s*\\2\\s*" + this.ctag +
    109               "\\s*", "mg");
     172
     173      var regex = this.getCachedRegex("render_section", function (otag, ctag) {
     174        // This regex matches _the first_ section ({{#foo}}{{/foo}}), and captures the remainder
     175        return new RegExp(
     176          "^([\\s\\S]*?)" +         // all the crap at the beginning that is not {{*}} ($1)
     177
     178          otag +                    // {{
     179          "(\\^|\\#)\\s*(.+)\\s*" + //  #foo (# == $2, foo == $3)
     180          ctag +                    // }}
     181
     182          "\n*([\\s\\S]*?)" +       // between the tag ($2). leading newlines are dropped
     183
     184          otag +                    // {{
     185          "\\/\\s*\\3\\s*" +        //  /foo (backreference to the opening tag).
     186          ctag +                    // }}
     187
     188          "\\s*([\\s\\S]*)$",       // everything else in the string ($4). leading whitespace is dropped.
     189
     190        "g");
     191      });
     192
    110193
    111194      // for each {{#foo}}{{/foo}} section do...
    112       return template.replace(regex, function(match, type, name, content) {
    113         var value = that.find(name, context);
    114         if(type == "^") { // inverted section
    115           if(!value || that.is_array(value) && value.length === 0) {
     195      return template.replace(regex, function (match, before, type, name, content, after) {
     196        // before contains only tags, no sections
     197        var renderedBefore = before ? that.render_tags(before, context, partials, true) : "",
     198
     199        // after may contain both sections and tags, so use full rendering function
     200            renderedAfter = after ? that.render(after, context, partials, true) : "",
     201
     202        // will be computed below
     203            renderedContent,
     204
     205            value = that.find(name, context);
     206
     207        if (type === "^") { // inverted section
     208          if (!value || Array.isArray(value) && value.length === 0) {
    116209            // false or empty list, render it
    117             return that.render(content, context, partials, true);
     210            renderedContent = that.render(content, context, partials, true);
    118211          } else {
    119             return "";
     212            renderedContent = "";
    120213          }
    121         } else if(type == "#") { // normal section
    122           if(that.is_array(value)) { // Enumerable, Let's loop!
    123             return that.map(value, function(row) {
    124               return that.render(content, that.create_context(row),
    125                 partials, true);
     214        } else if (type === "#") { // normal section
     215          if (Array.isArray(value)) { // Enumerable, Let's loop!
     216            renderedContent = that.map(value, function (row) {
     217              return that.render(content, that.create_context(row), partials, true);
    126218            }).join("");
    127           } else if(that.is_object(value)) { // Object, Use it as subcontext!
    128             return that.render(content, that.create_context(value),
     219          } else if (that.is_object(value)) { // Object, Use it as subcontext!
     220            renderedContent = that.render(content, that.create_context(value),
    129221              partials, true);
    130           } else if(typeof value === "function") {
     222          } else if (typeof value == "function") {
    131223            // higher order section
    132             return value.call(context, content, function(text) {
     224            renderedContent = value.call(context, content, function (text) {
    133225              return that.render(text, context, partials, true);
    134226            });
    135           } else if(value) { // boolean section
    136             return that.render(content, context, partials, true);
     227          } else if (value) { // boolean section
     228            renderedContent = that.render(content, context, partials, true);
    137229          } else {
    138             return "";
     230            renderedContent = "";
    139231          }
    140232        }
     233
     234        return renderedBefore + renderedContent + renderedAfter;
    141235      });
    142236    },
     
    145239      Replace {{foo}} and friends with values from our view
    146240    */
    147     render_tags: function(template, context, partials, in_recursion) {
     241    render_tags: function (template, context, partials, in_recursion) {
    148242      // tit for tat
    149243      var that = this;
    150244
    151       var new_regex = function() {
    152         return new RegExp(that.otag + "(=|!|>|\\{|%)?([^\\/#\\^]+?)\\1?" +
    153           that.ctag + "+", "g");
     245      var new_regex = function () {
     246        return that.getCachedRegex("render_tags", function (otag, ctag) {
     247          return new RegExp(otag + "(=|!|>|&|\\{|%)?([^#\\^]+?)\\1?" + ctag + "+", "g");
     248        });
    154249      };
    155250
    156251      var regex = new_regex();
    157       var tag_replace_callback = function(match, operator, name) {
     252      var tag_replace_callback = function (match, operator, name) {
    158253        switch(operator) {
    159254        case "!": // ignore comments
     
    166261          return that.render_partial(name, context, partials);
    167262        case "{": // the triple mustache is unescaped
     263        case "&": // & operator is an alternative unescape method
    168264          return that.find(name, context);
    169265        default: // escape the value
    170           return that.escape(that.find(name, context));
     266          return escapeHTML(that.find(name, context));
    171267        }
    172268      };
     
    174270      for(var i = 0; i < lines.length; i++) {
    175271        lines[i] = lines[i].replace(regex, tag_replace_callback, this);
    176         if(!in_recursion) {
     272        if (!in_recursion) {
    177273          this.send(lines[i]);
    178274        }
    179275      }
    180276
    181       if(in_recursion) {
     277      if (in_recursion) {
    182278        return lines.join("\n");
    183279      }
    184280    },
    185281
    186     set_delimiters: function(delimiters) {
     282    set_delimiters: function (delimiters) {
    187283      var dels = delimiters.split(" ");
    188284      this.otag = this.escape_regex(dels[0]);
     
    190286    },
    191287
    192     escape_regex: function(text) {
     288    escape_regex: function (text) {
    193289      // thank you Simon Willison
    194       if(!arguments.callee.sRE) {
     290      if (!arguments.callee.sRE) {
    195291        var specials = [
    196292          '/', '.', '*', '+', '?', '|',
     
    208304      from the view object
    209305    */
    210     find: function(name, context) {
    211       name = this.trim(name);
     306    find: function (name, context) {
     307      name = trim(name);
    212308
    213309      // Checks whether a value is thruthy or false or 0
     
    217313
    218314      var value;
    219       if(is_kinda_truthy(context[name])) {
    220         value = context[name];
    221       } else if(is_kinda_truthy(this.context[name])) {
    222         value = this.context[name];
    223       }
    224 
    225       if(typeof value === "function") {
     315
     316      // check for dot notation eg. foo.bar
     317      if (name.match(/([a-z_]+)\./ig)) {
     318        var childValue = this.walk_context(name, context);
     319        if (is_kinda_truthy(childValue)) {
     320          value = childValue;
     321        }
     322      } else {
     323        if (is_kinda_truthy(context[name])) {
     324          value = context[name];
     325        } else if (is_kinda_truthy(this.context[name])) {
     326          value = this.context[name];
     327        }
     328      }
     329
     330      if (typeof value == "function") {
    226331        return value.apply(context);
    227332      }
    228       if(value !== undefined) {
     333      if (value !== undefined) {
    229334        return value;
    230335      }
     
    233338    },
    234339
     340    walk_context: function (name, context) {
     341      var path = name.split('.');
     342      // if the var doesn't exist in current context, check the top level context
     343      var value_context = (context[path[0]] != undefined) ? context : this.context;
     344      var value = value_context[path.shift()];
     345      while (value != undefined && path.length > 0) {
     346        value_context = value;
     347        value = value[path.shift()];
     348      }
     349      // if the value is a function, call it, binding the correct context
     350      if (typeof value == "function") {
     351        return value.apply(value_context);
     352      }
     353      return value;
     354    },
     355
    235356    // Utility methods
    236357
    237358    /* includes tag */
    238     includes: function(needle, haystack) {
     359    includes: function (needle, haystack) {
    239360      return haystack.indexOf(this.otag + needle) != -1;
    240361    },
    241362
    242     /*
    243       Does away with nasty characters
    244     */
    245     escape: function(s) {
    246       s = String(s === null ? "" : s);
    247       return s.replace(/&(?!\w+;)|["<>\\]/g, function(s) {
    248         switch(s) {
    249         case "&": return "&amp;";
    250         case "\\": return "\\\\";
    251         case '"': return '\"';
    252         case "<": return "&lt;";
    253         case ">": return "&gt;";
    254         default: return s;
    255         }
    256       });
    257     },
    258 
    259363    // by @langalex, support for arrays of strings
    260     create_context: function(_context) {
    261       if(this.is_object(_context)) {
     364    create_context: function (_context) {
     365      if (this.is_object(_context)) {
    262366        return _context;
    263367      } else {
    264368        var iterator = ".";
    265         if(this.pragmas["IMPLICIT-ITERATOR"]) {
     369        if (this.pragmas["IMPLICIT-ITERATOR"]) {
    266370          iterator = this.pragmas["IMPLICIT-ITERATOR"].iterator;
    267371        }
     
    272376    },
    273377
    274     is_object: function(a) {
     378    is_object: function (a) {
    275379      return a && typeof a == "object";
    276380    },
    277381
    278     is_array: function(a) {
    279       return Object.prototype.toString.call(a) === '[object Array]';
    280     },
    281 
    282     /*
    283       Gets rid of leading and trailing whitespace
    284     */
    285     trim: function(s) {
    286       return s.replace(/^\s*|\s*$/g, "");
    287     },
    288 
    289382    /*
    290383      Why, why, why? Because IE. Cry, cry cry.
    291384    */
    292     map: function(array, fn) {
     385    map: function (array, fn) {
    293386      if (typeof array.map == "function") {
    294387        return array.map(fn);
     
    301394        return r;
    302395      }
     396    },
     397
     398    getCachedRegex: function (name, generator) {
     399      var byOtag = regexCache[this.otag];
     400      if (!byOtag) {
     401        byOtag = regexCache[this.otag] = {};
     402      }
     403
     404      var byCtag = byOtag[this.ctag];
     405      if (!byCtag) {
     406        byCtag = byOtag[this.ctag] = {};
     407      }
     408
     409      var regex = byCtag[name];
     410      if (!regex) {
     411        regex = byCtag[name] = generator(this.otag, this.ctag);
     412      }
     413
     414      return regex;
    303415    }
    304416  };
     
    306418  return({
    307419    name: "mustache.js",
    308     version: "0.3.0",
     420    version: "0.4.0",
    309421
    310422    /*
    311423      Turns a template and view into HTML
    312424    */
    313     to_html: function(template, view, partials, send_fun) {
     425    to_html: function (template, view, partials, send_fun) {
    314426      var renderer = new Renderer();
    315       if(send_fun) {
     427      if (send_fun) {
    316428        renderer.send = send_fun;
    317429      }
    318       renderer.render(template, view, partials);
    319       if(!send_fun) {
     430      renderer.render(template, view || {}, partials);
     431      if (!send_fun) {
    320432        return renderer.buffer.join("\n");
    321433      }
  • jazzy-forms/trunk/back/ctrl-forms.php

    r491567 r508925  
    1111        $json = stripcslashes($_POST['form']);
    1212        $form = json_decode($json);
    13         if(jzzf_set_form($form)) {
     13        if($current = jzzf_set_form($form)) {
    1414            $msg = "Form Saved.";
    1515        } else {
  • jazzy-forms/trunk/back/elements.js

    r502411 r508925  
    1616            placeholder.replaceWith(li);
    1717        } else {
    18             $('#jzzf_elements_list').append(html);
    19             li = $('#jzzf_elements_list li:last-child');
     18            li = $(html);
     19            $('#jzzf_elements_list').append(li);
    2020        }
    2121        if(collapsed === undefined || collapsed) {
     
    2828        var counter = this.counter();
    2929        data.counter = counter;
    30         data.typeString = $('#jzzf_elements_toolbox_items li[jzzf_type="' + data.type + '"]').text();
     30        data.display_title = this.display_title(data.title);
     31        data.typeString = $('.jzzf_elements_toolbox_items li[jzzf_type="' + data.type + '"]').text();
    3132        if(data.options) {
    3233            $.each(data.options, function(idx) {
     
    7475            return false;
    7576        });
     77        element.find('.jzzf_element_title').change(function() {
     78           element.find('.jzzf_header_title').text(self.display_title($(this).val()));
     79        });
    7680        element.find('.jzzf_option_table tbody').sortable();
    7781        this.bind_options();
     
    115119    }
    116120   
     121    this.display_title = function(title) {
     122        if(title.length >= 50) {
     123            return title.substring(0, 47) + '...';
     124        } else {
     125            return title;
     126        }
     127    }
     128   
    117129    this.options_data = function(li) {
    118130        var options = [];
  • jazzy-forms/trunk/back/gui.css

    r502411 r508925  
    2828    margin: 0 4px 0 0px;
    2929    border: 1px solid #ddd;
     30    border-top-left-radius: 3px;
     31    border-top-right-radius: 3px;
    3032    height: 13px;
    3133    z-index: 10;
    3234    background-color: #eee;
     35    cursor: pointer;
    3336}
    3437
     
    4447    padding: 20px;
    4548    border: 1px solid #ddd;
    46 }
    47 
    48 #jzzf_elements_toolbox {
     49    border-radius: 3px;
     50}
     51
     52.jzzf_elements_toolbox {
    4953    display: block;
    5054    overflow: visible;
    51     width: 200px;
     55    width: 350px;
    5256    float: left;
    5357    clear: both;
    5458}
    5559
    56 #jzzf_elements_toolbox_items items {
    57     padding: 10px;
    58 }
    59 
    60 #jzzf_elements_toolbox_items li {
     60.jzzf_elements_toolbox_items {
     61    display: block;
     62    padding: 10px 10px 4px 10px;
     63    overflow: hidden;
     64    background: #eee;
     65    border-radius: 3px;
     66    width: 148px;
     67    float: left;
     68}
     69
     70#jzzf_toolbox_input {
     71    margin-right: 10px;
     72}
     73
     74#jzzf_toolbox_buttons {
     75    margin-bottom: 10px;
     76}
     77
     78.jzzf_elements_toolbox_items li {
    6179    background: #ddd;
    6280    border: 1px solid #ccc;
     81    border-radius: 3px;
    6382    padding: 8px;
    64     height: 20px;
    65     width: 100px;
     83    height: 14px;
     84    width: 130px;
     85    cursor: move;
     86}
     87
     88.jzzf_elements_toolbox_items li:hover {
     89    background-color: #e8e8e8;
    6690}
    6791
     
    84108    overflow: hidden;
    85109    background: #eee;
     110    border-radius: 3px;
    86111}
    87112
     
    89114    margin: 5px;
    90115    border: 1px solid #ccc;
     116    border-radius: 3px;
    91117}
    92118
     
    95121    border-bottom: 1px solid #ddd;
    96122    padding: 8px;
    97     height: 20px;
     123    height: 14px;
     124    cursor: move;
     125}
     126
     127.jzzf_element.jzzf_collapsed .jzzf_element_header {
     128    border-bottom: none;
     129}
     130
     131.jzzf_element_header:hover {
     132    background-color: #e8e8e8;
    98133}
    99134
    100135.jzzf_element_header .jzzf_element_delete {
     136    width: 16px;
     137    height: 16px;
     138    background: url('img/del.png') no-repeat center;
    101139    float: right;
     140}
     141
     142.jzzf_element_header .jzzf_element_delete:hover {
     143    background: url('img/del_hi.png') no-repeat center;
    102144}
    103145
     
    105147    background: #fff;
    106148    padding: 8px 12px;
     149    border-bottom-left-radius: 3px;
     150    border-bottom-right-radius: 3px;
     151}
     152
     153.jzzf_element_body li {
     154    margin-bottom: 2px;
    107155}
    108156
     
    113161}
    114162
     163.jzzf_section .jzzf_checkbox_label {
     164    width: 400px;
     165}
     166
    115167.jzzf_section > ul > li > input[type=checkbox]  {
    116168    margin-right: 12px;
     
    146198    margin-right: 12px;
    147199}
     200
     201.jzzf_type {
     202    width: 16px;
     203    height: 16px;
     204    float: left;
     205    padding-right: 10px;
     206    background: url('img/u.png') no-repeat center;
     207}
     208
     209.jzzf_type_n { background-image: url('img/n.png'); }
     210.jzzf_type_c { background-image: url('img/c.png'); }
     211.jzzf_type_r { background-image: url('img/r.png'); }
     212.jzzf_type_d { background-image: url('img/d.png'); }
     213.jzzf_type_u { background-image: url('img/u.png'); }
     214.jzzf_type_f { background-image: url('img/f.png'); }
     215.jzzf_type_t { background-image: url('img/t.png'); }
     216.jzzf_type_h { background-image: url('img/h.png'); }
     217.jzzf_type_m { background-image: url('img/m.png'); }
  • jazzy-forms/trunk/back/gui.js

    r491567 r508925  
    11(function($) {
    22    var form = null;
     3    var form_index = 0;
     4    var dirty = false;
     5    var text_unload = "The current form has unsaved changes.";
     6    var text_dirty = text_unload + "\nAre you sure you want to discard them?";
    37   
    48    function new_element(type) {
     
    2832    }
    2933   
    30     function bind() {     
    31         $('#jzzf_elements_toolbox_items li').click(function() {
     34    function warn_unload() {
     35        return dirty ? text_unload : null;
     36    }
     37   
     38    function warn_dirty() {
     39        if(dirty) {
     40            return confirm(text_dirty);
     41        } else {
     42            return true;
     43        }
     44    }
     45   
     46    function mark_dirty() {
     47        if(!dirty) {
     48            dirty = true;
     49            window.onbeforeunload = warn_unload;
     50        }
     51        return true;
     52    }
     53   
     54    function mark_clean() {
     55        if(dirty) {
     56            dirty = false;
     57            window.onbeforeunload = null;
     58        }
     59        return true;
     60    }
     61   
     62    function bind() {
     63        $('#jzzf_main').delegate('input', 'change', mark_dirty);
     64       
     65        $('.jzzf_elements_toolbox_items li').click(function() {
    3266            add_element($(this), false);
    3367            return false;
     
    3973            }
    4074        });
    41         $('#jzzf_elements_toolbox_items li').draggable({
     75        $('.jzzf_elements_toolbox_items li').draggable({
    4276            connectToSortable: "#jzzf_elements_list",
    4377            helper: "clone",
    44             revert: "invalid"
     78            revert: "invalid",
     79            cursor: "move"
    4580        });
    4681
     
    5186                                             
    5287        $('#jzzf_selector').change(function() {
    53             set_current_form($('#jzzf_selector').val());
    54         });
    55        
    56         $('#jzzf_form *').delegate('*', 'click change sortupdate', function(event) {
     88            if(warn_dirty()) {
     89                set_current_form($('#jzzf_selector').val());
     90                return true;
     91            } else {
     92                reset_current_form();
     93                return false;
     94            }
     95        });
     96       
     97        $('#jzzf_form *, #jzzf_selection *').delegate('*', 'click change sortupdate', function(event) {
    5798            $('#message').hide();
    5899        });
     
    83124            $('#jzzf_name').val(form.name);
    84125            $('#jzzf_elements_list').html('');
     126            if(form.realtime == 1) {
     127                $('#jzzf_realtime').attr('checked', 'checked');
     128            } else {
     129                $('#jzzf_realtime').removeAttr('checked');
     130            }
    85131            for(var i=0; i<form.elements.length; i++) {
    86132                var element = jzzf_element.create(form.elements[i].type)
     
    108154            "name": $('#jzzf_name').val(),
    109155            "theme": $('#jzzf_default_css').is(':checked'),
     156            "realtime": $('#jzzf_realtime').is(':checked'),
    110157            "css": $('#jzzf_css').val(),
    111158            "elements": get_elements()
     
    114161   
    115162    function save() {
     163        window.onbeforeunload = null;
    116164        var form = get_form();
    117165        var serialized = JSON.stringify(form);
     
    124172        var id_helper = new jzzf_id(jzzf_forms);
    125173        var name = id_helper.suggest_name(title);
    126         form = {'title': title, 'name': name, 'elements': [], 'theme': 1};
     174        form = {'title': title, 'name': name, 'elements': [], 'theme': 1, 'realtime': true};
    127175        elements = [];
    128176        $('#jzzf_form').show();
     
    133181    }
    134182   
     183    function reset_current_form() {
     184        $('#jzzf_selector option:eq(' + form_index + ')').attr('selected', 'selected');
     185    }
     186   
    135187    function set_current_form(idx) {
     188        mark_clean();
    136189        form = jzzf_forms[idx];
     190        form_index = idx;
    137191        set_form(form);
    138192    }
     
    145199   
    146200    function new_form() {
    147         form = null;
    148         set_form(form);
     201        $('#message').hide();
     202        if(warn_dirty()) {
     203            form = null;
     204            set_form(form);           
     205        }
    149206    }
    150207   
    151208    $(function() {
     209        form_index = $('#jzzf_selector option:selected').index();
    152210        if(jzzf_forms.length == 0) {
    153211            new_form();
    154212        } else {
    155             set_current_form(0);
     213            set_current_form(form_index);
    156214        }
    157215        bind();
  • jazzy-forms/trunk/back/id.js

    r491567 r508925  
    1515        var idx = 1;
    1616        while(this.column_occupied(name, 'name')) {
    17             name = base + '-' + idx;
     17            name = base + '_' + idx;
    1818            idx++;
    1919        }
  • jazzy-forms/trunk/back/tpl-forms.php

    r495032 r508925  
    1 <script id="jzzf_tmpl_common" type="text/html">
     1<script id="jzzf_tmpl_common_raw" type="text/html">
    22<li class="jzzf_element">
    33    <input type="hidden" value="{{id}}" class="jzzf_element_id">
    44    <input type="hidden" value="{{counter}}" class="jzzf_element_counter">
     5    <input type="hidden" class="jzzf_element_type" value="{{type}}">
    56    <div class="jzzf_element_header">
    6         <span class="jzzf_type jzzf_type_{{type}}">[{{typeString}}]</span>
    7         <span class="jzzf_header_title">{{title}}</span>
    8         <a href="#" class="jzzf_element_delete">(x)</a>
     7        <div class="jzzf_type jzzf_type_{{type}}"></div>
     8        <span class="jzzf_header_title">{{display_title}}</span>
     9        <a href="#" class="jzzf_element_delete" title="Delete Element"></a>
    910    </div>
    1011    <div class="jzzf_element_body">
     12</script>
     13<script id="jzzf_tmpl_common" type="text/html">
     14{{>common_raw}}
    1115        <fieldset>
    1216            <ul class="jzzf_element_parameters">
    1317                <li>
    14                     <input type="hidden" class="jzzf_element_type" value="{{type}}">
    1518                    <label for="jzzf_element_{{counter}}_title">Title</label>
    1619                    <input type="text" id="jzzf_element_{{counter}}_title" class="jzzf_element_title" value="{{title}}">
     
    7881{{>common}}
    7982    <fieldset>
    80         <legend>Formula</legend>
    81         <label for="jzzf_element_{{counter}}_formula">Formula</label>
    82         <input type="text" id="jzzf_element_{{counter}}_formula" class="jzzf_element_formula" value="{{formula}}">
     83        <ul>
     84            <li>
     85                <legend>Formula</legend>
     86                <label for="jzzf_element_{{counter}}_formula">Formula</label>
     87                <input type="text" id="jzzf_element_{{counter}}_formula" class="jzzf_element_formula" value="{{formula}}">
     88            </li>
     89        </ul>
    8390    </fieldset>
    8491{{>foot}}
     
    8895{{>foot}}
    8996</script>
     97<script id="jzzf_tmpl_t" type="text/html">
     98{{>common_raw}}
     99    <fieldset>
     100        <ul>
     101            <li>
     102                <label for="jzzf_element_{{counter}}_title">Text</label>
     103                <input type="text" id="jzzf_element_{{counter}}_title" class="jzzf_element_title" value="{{title}}">
     104            </li>
     105        </ul>
     106    </fieldset>
     107{{>foot}}
     108</script>
     109<script id="jzzf_tmpl_h" type="text/html">
     110{{>common_raw}}
     111    <fieldset>
     112        <ul>
     113            <li>
     114                <label for="jzzf_element_{{counter}}_title">Heading</label>
     115                <input type="text" id="jzzf_element_{{counter}}_title" class="jzzf_element_title" value="{{title}}">
     116            </li>
     117        </ul>
     118    </fieldset>
     119{{>foot}}
     120</script>
     121<script id="jzzf_tmpl_m" type="text/html">
     122{{>common_raw}}
     123    <fieldset>
     124        <ul>
     125            <li>
     126                <label for="jzzf_element_{{counter}}_title">HTML code</label>
     127                <input type="text" id="jzzf_element_{{counter}}_title" class="jzzf_element_title" value="{{title}}">
     128            </li>
     129        </ul>
     130    </fieldset>
     131{{>foot}}
     132</script>
     133
    90134<script id="jzzf_tmpl_options" type="text/html">
    91135        <fieldset>
     
    126170    <select id="jzzf_selector">
    127171<?php $i=0; foreach($forms as $form) : ?>
    128         <option value="<?php echo $i++ ?>"><?php echo esc_attr($form->title) ?></option>
     172        <option value="<?php echo $i++ ?>"<?php if($form->id == $current) :?> selected="selected"<?php endif ?>><?php echo esc_attr($form->title) ?></option>
    129173<?php endforeach; ?>
    130174    </select>
     
    147191    <div id="jzzf_main">
    148192        <div class="jzzf_section" id="jzzf_section_elements">
    149             <div id="jzzf_elements_toolbox">
     193            <div class="jzzf_elements_toolbox">
    150194            <div class="jzzf_column_heading" id="jzzf_elements_toolbox_description">Available form elements</div>
    151                 <ul id="jzzf_elements_toolbox_items">
    152                     <li jzzf_type="n">Number Entry</li>
    153                     <li jzzf_type="d">Drop-down Menu</li>
    154                     <li jzzf_type="r">Radio Buttons</li>
    155                     <li jzzf_type="c">Checkbox</li>
    156                     <li jzzf_type="f">Output</li>
    157                     <li jzzf_type="u">Update Button</li>
     195                <ul id="jzzf_toolbox_input" class="jzzf_elements_toolbox_items">
     196                    <li jzzf_type="n"><div class="jzzf_type jzzf_type_n"></div>Number Entry</li>
     197                    <li jzzf_type="d"><div class="jzzf_type jzzf_type_d"></div>Drop-down Menu</li>
     198                    <li jzzf_type="r"><div class="jzzf_type jzzf_type_r"></div>Radio Buttons</li>
     199                    <li jzzf_type="c"><div class="jzzf_type jzzf_type_c"></div>Checkbox</li>
     200                    <li jzzf_type="f"><div class="jzzf_type jzzf_type_f"></div>Output</li>
     201                </ul>
     202                <ul id="jzzf_toolbox_buttons" class="jzzf_elements_toolbox_items">
     203                    <li jzzf_type="u"><div class="jzzf_type jzzf_type_u"></div>Update Button</li>
     204                </ul>
     205                <ul id="jzzf_toolbox_text" class="jzzf_elements_toolbox_items">
     206                    <li jzzf_type="t"><div class="jzzf_type jzzf_type_t"></div>Text</li>
     207                    <li jzzf_type="h"><div class="jzzf_type jzzf_type_h"></div>Heading</li>
     208                    <li jzzf_type="m"><div class="jzzf_type jzzf_type_m"></div>Free HTML</li>
    158209                </ul>
    159210            </div>
     
    194245                    </p>
    195246                </li>
    196                
     247                <li>
     248                    <input type="checkbox" id="jzzf_realtime">
     249                    <label for="jzzf_realtime" class="jzzf_checkbox_label">Update output elements instantly</label>
     250                </li>               
    197251            </ul>
    198252        </div>
  • jazzy-forms/trunk/core/Parser.php

    r502411 r508925  
    44    try {
    55        $tokens = jzzf_tokenize($notation);
     6        return jzzf_parse_tokens($tokens);
    67    } catch( Exception $e ) {
    78        return null;
    8     }
    9     return jzzf_parse_tokens($tokens);
     9    }       
    1010}
    1111
    1212function jzzf_parse_tokens($in) {
    13     $tokenizer = new Jzzf_Parser($in);
    14     return $tokenizer->output();
     13    try {
     14        $tokenizer = new Jzzf_Parser($in);
     15        return $tokenizer->output();
     16    } catch( Exception $e ) {
     17        return null;
     18    }       
    1519}
    1620
     
    103107                $result = array_merge($result, $next);
    104108                $num++;
     109            } else {
     110                throw new Exception("Closing bracket or comma expected");
    105111            }
    106112        }
     
    165171            return $this->association();
    166172        }
    167         return array();
     173        return null;
    168174    }
    169175}
  • jazzy-forms/trunk/front/ctrl-shortcode.php

    r499961 r508925  
    2727    }
    2828    $graph = jzzf_get_graph($form->elements);
    29     $tpl->graph($form, $graph);
     29    $tpl->graph(jzzf_form_params($form), $graph);
    3030    $tpl->script($form);
    3131    $tpl->head($form);
    32     foreach($form->elements as $element) {
    33         $tpl->before($element);
     32    for($idx=0; $idx<count($form->elements); $idx++) {
     33        $element = $form->elements[$idx];
     34        if($idx < count($form->elements)-1) {
     35            $ahead = $form->elements[$idx+1];
     36        } else {
     37            $ahead = null;
     38        }
     39        $tpl->before($element, $ahead);
     40       
    3441        switch($element->type) {
    3542            case 'n':
     
    5461                $tpl->update($element);
    5562                break;
     63            case 'h':
     64                $tpl->heading($element);
     65                break;
     66            case 't':
     67                $tpl->text($element);
     68                break;
     69            case 'm':
     70                $tpl->html($element);
     71                break;
    5672        }
    5773        $tpl->after($element);
     
    6177    return $output;
    6278}
     79
     80function jzzf_form_params($form) {
     81    $params = clone $form;
     82    unset($params->elements);
     83    unset($params->css);   
     84    return $params;
     85
     86}
  • jazzy-forms/trunk/front/jazzy-forms.js

    r502411 r508925  
    1 function jazzy_forms($, form_id, jzzf_data, jzzf_types, jzzf_dependencies, jzzf_formulas) {
     1function jazzy_forms($, form_id, jzzf_data, jzzf_types, jzzf_dependencies, jzzf_formulas, jzzf_params) {
    22   
    33    jzzf_precision = Math.pow(10,9);
     
    2424        for(id in jzzf_types) {
    2525            update(id);
    26             switch(jzzf_types[id]) {
    27                 case 'r':
    28                     element(id).find('input:radio').bind('change ready', function() {
    29                         update(element_id($(this).parents('.jzzf_radio')));
    30                     });
    31                     break;
    32                 default:
    33                     element(id).bind('change ready', function() {
    34                         update(element_id($(this)));
    35                     });
    36                    
    37             }
    38         }
    39     }
    40 
     26            if(jzzf_params.realtime) {
     27                bind_realtime_update(id);
     28            }
     29            if(jzzf_types[id] == 'u') {
     30                element(id).click(function() {
     31                    var id;
     32                    for(id in jzzf_types) {
     33                        update(id);
     34                    }
     35                });
     36            }
     37        }
     38    }
     39
     40    function bind_realtime_update(id) {
     41        switch(jzzf_types[id]) {
     42        case 'r':
     43            element(id).find('input:radio').bind('change ready', function() {
     44                update(element_id($(this).parents('.jzzf_radio')));
     45            });
     46            break;
     47        default:
     48            element(id).bind('change ready', function() {
     49                update(element_id($(this)));
     50            });
     51        }
     52    }
     53   
    4154    var just_updated;
    4255   
  • jazzy-forms/trunk/front/themes/1.css

    r491567 r508925  
    2121}
    2222
    23 .jzzf_form .jzzf_element_label {
     23.jzzf_form .jzzf_element_label, .jzzf_form .jzzf_element_heading {
    2424    display: block;
    2525    font-weight: bold;
     
    2828.jzzf_form .jzzf_element {
    2929    padding-bottom: 1em;
     30}
     31
     32.jzzf_form .jzzf_element_c.jzzf_ahead_c {
     33    padding-bottom: inherit;
     34}
     35
     36.jzzf_form .jzzf_element_h {
     37    font-weight: bold;
     38}
     39
     40.jzzf_form .jzzf_element_h.jzzf_ahead_c, .jzzf_form .jzzf_element_h.jzzf_ahead_m, .jzzf_form .jzzf_element_h.jzzf_ahead_t {
     41    padding-bottom: inherit;
    3042}
    3143
  • jazzy-forms/trunk/front/tmpl-list.php

    r502411 r508925  
    2323   
    2424    function css($css) { ?>
    25     <style type="text/css">
     25    <style type="text/css" scoped="scoped">
    2626        <?php print $css; ?>
    2727
     
    3636        jzzf_dependencies_<?php echo $form->id ?> = <?php echo json_encode($dependencies) ?>;
    3737        jzzf_formulas_<?php echo $form->id ?> = <?php echo json_encode($formulas) ?>;
    38         jazzy_forms(jQuery, <?php echo $form->id ?>, jzzf_data_<?php echo $form->id ?>, jzzf_types_<?php echo $form->id ?>, jzzf_dependencies_<?php echo $form->id ?>, jzzf_formulas_<?php echo $form->id ?>);
     38        jzzf_form_<?php echo $form->id ?> = <?php echo json_encode($form) ?>;
     39        jazzy_forms(jQuery, <?php echo $form->id ?>, jzzf_data_<?php echo $form->id ?>, jzzf_types_<?php echo $form->id ?>, jzzf_dependencies_<?php echo $form->id ?>, jzzf_formulas_<?php echo $form->id ?>, jzzf_form_<?php echo $form->id ?>);
    3940    </script>
    4041<?php
     
    4748    }
    4849   
    49     function before($element) { ?>
    50   <li class="jzzf_element">
     50    function before($element, $ahead) { ?>
     51  <li class="jzzf_element jzzf_element_<?php echo $element->type ?> jzzf_ahead_<?php echo $ahead ? $ahead->type : "end" ?>">
    5152<?php
    5253    }
     
    5859   
    5960    function number($element) { ?>
    60     <label class="jzzf_number_label jzzf_element_label" for="jzzf_<?php esc_attr_e($element->name) ?>"><?php esc_html_e($element->title) ?></label>
     61    <label class="jzzf_number_label jzzf_element_label" for="<?php $this->id($element) ?>"><?php esc_html_e($element->title) ?></label>
    6162    <input type="text" id="<?php $this->id($element) ?>" value="<?php esc_attr_e($element->default) ?>">
    6263<?php
     
    108109    }
    109110
     111    function heading($element) { ?>
     112        <?php esc_html_e($element->title) ?>
     113<?php
     114    }
     115
     116    function text($element) { ?>
     117        <?php esc_html_e($element->title) ?>
     118<?php
     119    }
     120
     121    function html($element) { ?>
     122        <?php echo $element->title ?>
     123<?php
     124    }
     125
     126
    110127    function foot($form) { ?>
    111128</ul>
  • jazzy-forms/trunk/generated/Basic_Model.php

    r491567 r508925  
    88    $obj->id = intval($obj->id);
    99    $obj->theme = intval($obj->theme);
     10    $obj->realtime = (bool) ($obj->realtime);
    1011            $obj->elements = jzzf_list_element($obj->id);
    1112        }
     
    2122    $obj->id = intval($obj->id);
    2223    $obj->theme = intval($obj->theme);
     24    $obj->realtime = (bool) ($obj->realtime);
    2325        $obj->elements = jzzf_list_element($obj->id);
    2426    }
     
    3335    $obj->id = intval($obj->id);
    3436    $obj->theme = intval($obj->theme);
     37    $obj->realtime = (bool) ($obj->realtime);
    3538        $obj->elements = jzzf_list_element($obj->id);
    3639    }
     
    4144    global $wpdb;
    4245    if($obj->id) {
    43         $query = "UPDATE {$wpdb->prefix}jzzf_form SET `title`=%s,`name`=%s,`theme`=%d,`css`=%s WHERE id=%d";
    44         $sql = $wpdb->prepare($query, $obj->title,$obj->name,$obj->theme,$obj->css, $obj->id);
     46        $query = "UPDATE {$wpdb->prefix}jzzf_form SET `title`=%s,`name`=%s,`theme`=%d,`css`=%s,`realtime`=%d WHERE id=%d";
     47        $sql = $wpdb->prepare($query, $obj->title,$obj->name,$obj->theme,$obj->css,$obj->realtime, $obj->id);
    4548        $result = $wpdb->query($sql);
    4649        $id = $obj->id;
    4750    } else {
    48         $query = "INSERT INTO {$wpdb->prefix}jzzf_form (`title`,`name`,`theme`,`css`) VALUES (%s,%s,%d,%s)";
    49         $sql = $wpdb->prepare($query, $obj->title,$obj->name,$obj->theme,$obj->css);
     51        $query = "INSERT INTO {$wpdb->prefix}jzzf_form (`title`,`name`,`theme`,`css`,`realtime`) VALUES (%s,%s,%d,%s,%d)";
     52        $sql = $wpdb->prepare($query, $obj->title,$obj->name,$obj->theme,$obj->css,$obj->realtime);
    5053        $result = $wpdb->query($sql);
    5154        $id = $wpdb->insert_id;
     
    7477            }
    7578        }
    76     }
    77     return $result!==false;
     79        return $id;
     80    }
     81    return false;
    7882}
    7983function jzzf_delete_form($id) {
     
    130134    global $wpdb;
    131135    if($obj->id) {
    132         $query = "UPDATE {$wpdb->prefix}jzzf_element SET `form`=%d,`order`=%d,`type`=%s,`title`=%s,`name`=%s,`formula`=%s,`value`=%s,`value2`=%s,`default`=%s,`external`=%s,`params`=%s WHERE id=%d";
     136        $query = "UPDATE {$wpdb->prefix}jzzf_element SET `form`=%d,`order`=%d,`type`=%s,`title`=%s,`name`=%s,`formula`=%s,`value`=%s,`value2`=%s,`default`=%s,`external`=%d,`params`=%s WHERE id=%d";
    133137        $sql = $wpdb->prepare($query, $obj->form,$obj->order,$obj->type,$obj->title,$obj->name,$obj->formula,$obj->value,$obj->value2,$obj->default,$obj->external,$obj->params, $obj->id);
    134138        $result = $wpdb->query($sql);
    135139        $id = $obj->id;
    136140    } else {
    137         $query = "INSERT INTO {$wpdb->prefix}jzzf_element (`form`,`order`,`type`,`title`,`name`,`formula`,`value`,`value2`,`default`,`external`,`params`) VALUES (%d,%d,%s,%s,%s,%s,%s,%s,%s,%s,%s)";
     141        $query = "INSERT INTO {$wpdb->prefix}jzzf_element (`form`,`order`,`type`,`title`,`name`,`formula`,`value`,`value2`,`default`,`external`,`params`) VALUES (%d,%d,%s,%s,%s,%s,%s,%s,%s,%d,%s)";
    138142        $sql = $wpdb->prepare($query, $obj->form,$obj->order,$obj->type,$obj->title,$obj->name,$obj->formula,$obj->value,$obj->value2,$obj->default,$obj->external,$obj->params);
    139143        $result = $wpdb->query($sql);
     
    163167            }
    164168        }
    165     }
    166     return $result!==false;
     169        return $id;
     170    }
     171    return false;
    167172}
    168173function jzzf_delete_element($id) {
     
    204209    global $wpdb;
    205210    if($obj->id) {
    206         $query = "UPDATE {$wpdb->prefix}jzzf_option SET `order`=%d,`element`=%d,`default`=%s,`title`=%s,`name`=%s,`value`=%s WHERE id=%d";
     211        $query = "UPDATE {$wpdb->prefix}jzzf_option SET `order`=%d,`element`=%d,`default`=%d,`title`=%s,`name`=%s,`value`=%s WHERE id=%d";
    207212        $sql = $wpdb->prepare($query, $obj->order,$obj->element,$obj->default,$obj->title,$obj->name,$obj->value, $obj->id);
    208213        $result = $wpdb->query($sql);
    209214        $id = $obj->id;
    210215    } else {
    211         $query = "INSERT INTO {$wpdb->prefix}jzzf_option (`order`,`element`,`default`,`title`,`name`,`value`) VALUES (%d,%d,%s,%s,%s,%s)";
     216        $query = "INSERT INTO {$wpdb->prefix}jzzf_option (`order`,`element`,`default`,`title`,`name`,`value`) VALUES (%d,%d,%d,%s,%s,%s)";
    212217        $sql = $wpdb->prepare($query, $obj->order,$obj->element,$obj->default,$obj->title,$obj->name,$obj->value);
    213218        $result = $wpdb->query($sql);
    214219        $id = $wpdb->insert_id;
    215220    }
    216     return $result!==false;
     221    return false;
    217222}
    218223function jzzf_delete_option($id) {
  • jazzy-forms/trunk/generated/schema.sql

    r495032 r508925  
    1 CREATE TABLE IF NOT EXISTS {{prefix}}jzzf_form ( id bigint(20) AUTO_INCREMENT, `title` varchar(1024) NOT NULL,`name` varchar(1024) NOT NULL,`theme` int(12) NOT NULL,`css` varchar(1024) NOT NULL, PRIMARY KEY (id) ) {{charset_collate}};
    2 CREATE TABLE IF NOT EXISTS {{prefix}}jzzf_element ( id bigint(20) AUTO_INCREMENT, `form` bigint(20) NOT NULL,`order` int(12) NOT NULL,`type` varchar(1024) NOT NULL,`title` varchar(1024) NOT NULL,`name` varchar(1024) NOT NULL,`formula` varchar(1024) NOT NULL,`value` varchar(1024) NOT NULL,`value2` varchar(1024) NOT NULL,`default` varchar(1024) NOT NULL,`external` int(1) NOT NULL,`params` varchar(2048) NOT NULL, PRIMARY KEY (id) ) {{charset_collate}};
    3 CREATE TABLE IF NOT EXISTS {{prefix}}jzzf_option ( id bigint(20) AUTO_INCREMENT, `order` int(12) NOT NULL,`element` bigint(20) NOT NULL,`default` int(1) NOT NULL,`title` varchar(1024) NOT NULL,`name` varchar(1024) NOT NULL,`value` varchar(1024) NOT NULL, PRIMARY KEY (id) ) {{charset_collate}};
     1CREATE TABLE IF NOT EXISTS {{prefix}}jzzf_form ( id bigint(20) AUTO_INCREMENT, `title` varchar(1024) NOT NULL, `name` varchar(1024) NOT NULL, `theme` int(12) NOT NULL, `css` varchar(1024) NOT NULL, `realtime` int(1) NOT NULL DEFAULT 1, PRIMARY KEY (id) ) {{charset_collate}};
     2CREATE TABLE IF NOT EXISTS {{prefix}}jzzf_element ( id bigint(20) AUTO_INCREMENT, `form` bigint(20) NOT NULL, `order` int(12) NOT NULL, `type` varchar(1024) NOT NULL, `title` varchar(1024) NOT NULL, `name` varchar(1024) NOT NULL, `formula` varchar(1024) NOT NULL, `value` varchar(1024) NOT NULL, `value2` varchar(1024) NOT NULL, `default` varchar(1024) NOT NULL, `external` int(1) NOT NULL, `params` varchar(2048) NOT NULL, PRIMARY KEY (id) ) {{charset_collate}};
     3CREATE TABLE IF NOT EXISTS {{prefix}}jzzf_option ( id bigint(20) AUTO_INCREMENT, `order` int(12) NOT NULL, `element` bigint(20) NOT NULL, `default` int(1) NOT NULL, `title` varchar(1024) NOT NULL, `name` varchar(1024) NOT NULL, `value` varchar(1024) NOT NULL, PRIMARY KEY (id) ) {{charset_collate}};
  • jazzy-forms/trunk/jazzy-forms.php

    r502411 r508925  
    44Plugin URI: http://www.jazzyforms.com/
    55Description: Online form builder
    6 Version: 0.9.3
     6Version: 0.9.4
    77Author: Igor Prochazka
    88Author URI: http://www.l90r.com/
     
    2727---------------------------------------------------------------------
    2828*/
     29
     30define(JZZF_VERSION, 0.0904);
    2931
    3032define(JZZF_ROOT, WP_PLUGIN_DIR . '/jazzy-forms/');
     
    6769function jzzf_activate() {
    6870    global $wpdb;
    69     $schema = file( dirname(__FILE__) . '/generated/schema.sql' );
    7071
    7172    if(!empty($wpdb->charset)) {
     
    7677        $charset_collate .= " COLLATE $wpdb->collate";
    7778    }
    78        
    79     foreach($schema as $line) {
     79   
     80    jzzf_create_tables($charset_collate);
     81    jzzf_update($charset_collate);
     82}
     83
     84function jzzf_create_tables($charset_collate) {
     85    jzzf_execute_sql('schema.sql', $charset_collate);
     86}
     87
     88function jzzf_execute_sql($filename, $charset_collate) {
     89    global $wpdb;
     90
     91    $file = file( dirname(__FILE__) . '/generated/' . $filename );
     92    foreach($file as $line) {
    8093        $sql = trim($line);
    8194        if($sql && $sql[0] != '#') {
     
    8598        }
    8699    }
     100}
     101
     102function jzzf_update($charset_collate) {
     103    $previous = get_option('jzzf_version', 0.0);
     104    update_option('jzzf_version', JZZF_VERSION);
     105   
     106    jzzf_execute_sql('update.sql', $charset_collate);   
    87107}
    88108
  • jazzy-forms/trunk/readme.txt

    r502411 r508925  
    55Requires at least: 3.2.1
    66Tested up to: 3.3.1
    7 Stable tag: 0.9.3
     7Stable tag: 0.9.4
    88
    99Jazzy Forms is an online form generator that performs instant calculations. It's ideal for inter-active price calculators.
     
    2727* Output
    2828* Update button
     29* Text/Heading/HTML
    2930
    3031This is an early release. Features like input validation, data collection or Email are still being worked on.
     
    4849Simply insert the following shortcode in the post or page you want the form to appear in:
    4950
    50 [jazzy form="FORM_ID"]
     51`[jazzy form="FORM_ID"]`
    5152
    5253Replace FORM_ID with the ID of the form you want to add. The complete shortcode for your form is also displayed on its administration screen in the "General" tab. Copy and paste it from there.
     
    8586
    8687where "base_price", "price", "quantity" and "tax" are IDs of other existing form elements.
     88While the author is still working on a proper documentation, you can preview a list of available functions at https://gist.github.com/1779127
    8789
    8890= Do you accept donations? =
     
    103105
    104106== Changelog ==
     107
     108= 0.9.4 =
     109* Some GUI polishing
     110* Treat quotes correctly on the back-end
     111* Avoid crashes/freeze on formulas with unbalanced paranthesis
     112* Add extra elements for text, heading and raw HTML
     113* Make real-time updating optional
     114* Generate valid HTML5 code
    105115
    106116= 0.9.3 =
Note: See TracChangeset for help on using the changeset viewer.