This commit is contained in:
Sacha Greif 2014-12-03 09:10:14 +09:00
parent 17431dfb87
commit eda570d66f
4 changed files with 3 additions and 541 deletions

View file

@ -3,97 +3,5 @@
<div class="grid grid-module">
{{> quickForm collection="Posts" doc=post id="editPostForm" template="telescope" label-class="control-label" input-col-class="controls"}}
</div>
<!--
<div class="grid submit">
{{#with post}}
<form class="grid-block form-horizontal">
<div class="control-group">
<label class="control-label post-form-headline">{{_ "created"}}</label>
<div class="controls"><p>{{created}}</p></div>
</div>
<div class="control-group">
<label class="control-label post-form-headline">{{_ "title"}}</label>
<div class="controls"><input id="title" type="text" value="{{title}}" /></div>
</div>
<div class="control-group">
<label class="control-label post-form-url">{{_ "url"}}</label>
<div class="controls"><input id="url" type="text" value="{{url}}" /></div>
</div>
{{#if shorten}}
<div class="control-group">
<label class="control-label post-form-url">{{_ "short_url"}}</label>
<div class="controls"><input id="short-url" type="text" value="{{shortUrl}}" /></div>
</div>
{{/if}}
<div class="control-group">
<label class="control-label post-form-body">{{_ "body"}}</label>
<div class="controls" id="editor"><textarea id="body" value="" class="input-xlarge">{{body}}</textarea></div>
</div>
{{#if categoriesEnabled}}
<div class="control-group post-form-category">
<label class="control-label">{{_ "categories"}}</label>
<div class="controls">
{{#each categories}}
<label class="radio inline">
<input id="category_{{_id}}" type="checkbox" value="{{_id}}" name="category" {{checked}} /> {{name}}
</label>
{{/each}}
</div>
</div>
{{/if}}
{{#if isAdmin}}
<div class="control-group post-form-sticky">
<label class="control-label">{{_ "inactive_"}}</label>
<div class="controls">
{{inactive}}
</div>
</div>
<div class="control-group post-form-sticky">
<label class="control-label">{{_ "sticky_"}}</label>
<div class="controls">
<input type="checkbox" name="sticky" id="sticky" {{isSticky}} />
</div>
</div>
<div class="control-group post-form-user">
<label class="control-label">{{_ "user"}}</label>
<div class="controls">
<select id="postUser">
{{#each users}}
<option {{isSelected ..}} value="{{_id}}">{{userName}}</option>
{{/each}}
</select>
</div>
</div>
<div class="control-group post-form-status">
<label class="control-label">{{_ "status_"}}</label>
<div class="controls">
<label class="radio inline">
<input id="status_pending" type="radio" value="1" name="status" {{hasStatusPending}} /> {{_ "pending"}}
</label>
<label class="radio inline">
<input id="status_approved" type="radio" value="2" name="status" {{hasStatusApproved}} /> {{_ "approved"}}
</label>
<label class="radio inline">
<input id="status_rejected" type="radio" value="3" name="status" {{hasStatusRejected}} /> {{_ "rejected"}}
</label>
</div>
</div>
<div id="postedAt" class={{showPostedAt}}>
<div class="control-group">
<label class="control-label post-form-date">{{_ "posted_date"}}</label>
<div class="controls"><input id="postedAtDate" type="text" value="{{postedAtDate}}" /></div>
</div>
<div class="control-group">
<label class="control-label post-form-time">{{_ "posted_time"}}</label>
<div class="controls"><input id="postedAtTime" type="text" value="{{postedAtTime}}" /></div>
</div>
</div>
{{/if}}
<div class="form-actions">
<a class="delete-link" href="/posts/deleted">{{_ "delete_post"}}</a>
<input type="submit" class="button" value="{{_ "submit"}}" />
</div>
</form>
{{/with}}
</div> -->
</template>

View file

@ -57,221 +57,4 @@ AutoForm.hooks({
// beginSubmit: function(formId, template) {},
// endSubmit: function(formId, template) {}
}
});
// Template[getTemplate('post_edit')].helpers({
// created: function(){
// return moment(this.createdAt).format("MMMM Do, h:mm:ss a");
// },
// categories: function(){
// var post = this;
// return Categories.find({}, {sort: {order: 1, name: 1}}).map(function(category) {
// category.checked = _.contains(_.pluck(post.categories, '_id'), category._id) ? 'checked' : '';
// return category;
// });
// },
// categoriesEnabled: function(){
// return Categories.find().count();
// },
// showPostedAt: function () {
// if((Session.get('currentPostStatus') || this.status) == STATUS_APPROVED){
// return 'visible'
// }else{
// return 'hidden'
// }
// },
// isSticky: function(){
// return this.sticky ? 'checked' : '';
// },
// isSelected: function(parentPost){
// return parentPost && this._id == parentPost.userId ? 'selected' : '';
// },
// postedAtDate: function(){
// return !!this.postedAt ? moment(this.postedAt).format("MM/DD/YYYY") : null;
// },
// postedAtTime: function(){
// return !!this.postedAt ? moment(this.postedAt).format("HH:mm") : null;
// },
// users: function(){
// return Meteor.users.find({}, {sort: {'profile.name': 1}});
// },
// userName: function(){
// return getDisplayName(this);
// },
// hasStatusPending: function(){
// return this.status == STATUS_PENDING ? 'checked' : '';
// },
// hasStatusApproved: function(){
// return this.status == STATUS_APPROVED ? 'checked' : '';
// },
// hasStatusRejected: function(){
// return this.status == STATUS_REJECTED ? 'checked' : '';
// },
// shorten: function(){
// return !!getSetting('bitlyToken');
// }
// });
// Template[getTemplate('post_edit')].rendered = function(){
// // run all post edit rendered callbacks
// var instance = this;
// postEditRenderedCallbacks.forEach(function(callback) {
// callback(instance);
// });
// Session.set('currentPostStatus', this.status);
// var post = this.data.post;
// if(post && !this.editor){
// this.editor= new EpicEditor(EpicEditorOptions).load();
// this.editor.importFile('editor', post.body);
// }
// // $("#postUser").selectToAutocomplete(); // XXX
// };
// Template[getTemplate('post_edit')].events({
// 'change input[name=status]': function (e, i) {
// Session.set('currentPostStatus', e.currentTarget.value);
// },
// 'click input[type=submit]': function(e, instance){
// var post = this;
// var updateObject = {};
// e.preventDefault();
// $(e.target).addClass('disabled');
// if(!Meteor.user()){
// throwError('You must be logged in.');
// return false;
// }
// // ------------------------------ Properties ------------------------------ //
// // Basic Properties
// var body = instance.editor.exportFile();
// var properties = {
// title: $('#title').val(),
// body: body,
// categories: []
// };
// // URL
// var url = $('#url').val();
// if(!!url){
// properties.url = (url.substring(0, 7) == "http://" || url.substring(0, 8) == "https://") ? url : "http://"+url;
// } else {
// // if URL is empty, unset it
// updateObject.$unset = {url: ""};
// }
// // ShortURL
// var shortUrl = $('#short-url').val();
// if(!!shortUrl)
// properties.shortUrl = shortUrl;
// // ------------------------------ Admin Properties ------------------------------ //
// if(isAdmin(Meteor.user())){
// // Basic Properties
// adminProperties = {
// sticky: $('#sticky').is(':checked'),
// userId: $('#postUser').val()
// };
// // Status
// adminProperties.status = parseInt($('input[name=status]:checked').val());
// properties = _.extend(properties, adminProperties);
// // PostedAt
// if(adminProperties.status == STATUS_APPROVED){
// var $postedAtDate = $('#postedAtDate');
// var $postedAtTime = $('#postedAtTime');
// var setPostedAt = false;
// var postedAt = new Date(); // default to current browser date and time
// var postedAtDate = $postedAtDate.datepicker('getDate');
// var postedAtTime = $postedAtTime.val();
// if($postedAtDate.exists() && postedAtDate != "Invalid Date"){ // if custom date is set, use it
// postedAt = postedAtDate;
// setPostedAt = true;
// }
// if($postedAtTime.exists() && postedAtTime.split(':').length==2){ // if custom time is set, use it
// var hours = postedAtTime.split(':')[0];
// var minutes = postedAtTime.split(':')[1];
// postedAt = moment(postedAt).hour(hours).minute(minutes).toDate();
// setPostedAt = true;
// }
// if(setPostedAt){ // if either custom date or time has been set, pass result to method
// Meteor.call('setPostedAt', post, postedAt); // use a method to guarantee timestamp integrity
// }else{
// Meteor.call('setPostedAt', post);
// }
// }
// }
// // ------------------------------ Callbacks ------------------------------ //
// // run all post edit client callbacks on properties object successively
// properties = postEditClientCallbacks.reduce(function(result, currentFunction) {
// return currentFunction(result);
// }, properties);
// // console.log(properties)
// // ------------------------------ Update ------------------------------ //
// if (properties) {
// updateObject.$set = properties;
// Posts.update(post._id, updateObject, function(error){
// if(error){
// console.log(error);
// throwError(error.message);
// clearSeenErrors();
// $(e.target).removeClass('disabled');
// }else{
// trackEvent("edit post", {'postId': post._id});
// Router.go("/posts/"+post._id);
// }
// });
// } else {
// $(e.target).removeClass('disabled');
// }
// },
// 'click .delete-link': function(e){
// var post = this;
// e.preventDefault();
// if(confirm("Are you sure?")){
// Router.go("/");
// Meteor.call("deletePostById", post._id, function(error) {
// if (error) {
// console.log(error);
// throwError(error.reason);
// } else {
// throwError('Your post has been deleted.');
// }
// });
// }
// }
// });
});

View file

@ -3,79 +3,5 @@
<div class="grid grid-module">
{{> quickForm collection="Posts" id="submitPostForm" template="telescope" label-class="control-label" input-col-class="controls"}}
</div>
<!-- <div class="grid submit">
<form class="grid-block form-horizontal">
<div class="control-group">
<label class="control-label">{{_ "url"}}</label>
<div class="controls"><input id="url" type="text" value="" /></div>
</div>
<div class="control-group">
<label class="control-label">{{_ "title"}}</label>
<div class="controls"><input id="title" type="text" value="" /><a href="#" class="get-title-link inline-link">{{_ "suggest_title"}}</a></div>
</div>
<div class="control-group">
<label class="control-label">{{_ "body"}}</label>
<div class="controls" id="editor"><textarea id="body" value="" class="input-xlarge"></textarea></div>
</div>
{{#if categoriesEnabled}}
<div class="control-group">
<label class="control-label">{{_ "category"}}</label>
<div class="controls">
{{#each categories}}
<label class="radio inline">
<input id="category_{{_id}}" type="checkbox" value="{{_id}}" name="category" /> {{name}}
</label>
{{/each}}
</div>
</div>
{{/if}}
{{#if isAdmin}}
<div class="control-group">
<label class="control-label">{{_ "sticky_"}}</label>
<div class="controls">
<input type="checkbox" name="sticky" id="sticky" />
</div>
</div>
<div class="control-group">
<label class="control-label">{{_ "user"}}</label>
<div class="controls">
<select id="postUser">
{{#each users}}
<option {{isSelected this}} value="{{_id}}">{{userName}}</option>
{{/each}}
</select>
</div>
</div>
<div class="control-group">
<label class="control-label">{{_ "status_"}}</label>
<div class="controls">
<label class="radio inline">
<input id="status_pending" type="radio" value="1" name="status"/> {{_ "pending"}}
</label>
<label class="radio inline">
<input id="status_approved" type="radio" value="2" name="status" checked /> {{_ "approved"}}
</label>
<label class="radio inline">
<input id="status_rejected" type="radio" value="3" name="status"/> {{_ "rejected"}}
</label>
</div>
</div>
<div id="postedAt" class={{showPostedAt}}>
<div class="control-group">
<label class="control-label post-form-date">{{_ "posted_date"}}</label>
<div class="controls"><input id="postedAtDate" type="text" value="{{postedAtDate}}" /></div>
</div>
<div class="control-group">
<label class="control-label post-form-time">{{_ "posted_time"}}</label>
<div class="controls"><input id="postedAtTime" type="text" value="{{postedAtTime}}" /></div>
</div>
<p class="help-block">{{_ "leave_blank_to_post_at_current_time"}}</p>
</div>
{{/if}}
<div class="form-actions">
<input type="submit" class="button" value="{{_ "submit"}}" />
</div>
</form>
</div> -->
</template>

View file

@ -65,159 +65,4 @@ AutoForm.hooks({
// beginSubmit: function(formId, template) {},
// endSubmit: function(formId, template) {}
}
});
// Template[getTemplate('post_submit')].helpers({
// categoriesEnabled: function(){
// return Categories.find().count();
// },
// categories: function(){
// return Categories.find();
// },
// users: function(){
// return Meteor.users.find({}, {sort: {'profile.name': 1}});
// },
// userName: function(){
// return getDisplayName(this);
// },
// isSelected: function(user){
// return user._id == Meteor.userId() ? "selected" : "";
// },
// showPostedAt: function () {
// if(Session.get('currentPostStatus') == STATUS_APPROVED){
// return 'visible'
// }else{
// return 'hidden'
// }
// // return (Session.get('currentPostStatus') || STATUS_APPROVED) == STATUS_APPROVED; // default to approved
// }
// });
// Template[getTemplate('post_submit')].rendered = function(){
// // run all post submit rendered callbacks
// var instance = this;
// postSubmitRenderedCallbacks.forEach(function(callback) {
// callback(instance);
// });
// Session.set('currentPostStatus', STATUS_APPROVED);
// Session.set('selectedPostId', null);
// if(!this.editor && $('#editor').exists())
// this.editor= new EpicEditor(EpicEditorOptions).load();
// // $("#postUser").selectToAutocomplete(); // XXX
// };
Template[getTemplate('post_submit')].events({
// 'change input[name=status]': function (e, i) {
// Session.set('currentPostStatus', e.currentTarget.value);
// },
// 'click input[type=submit]': function(e, instance){
// e.preventDefault();
// $(e.target).addClass('disabled');
// // ------------------------------ Checks ------------------------------ //
// if(!Meteor.user()){
// throwError(i18n.t('you_must_be_logged_in'));
// return false;
// }
// // ------------------------------ Properties ------------------------------ //
// // Basic Properties
// var properties = {
// title: $('#title').val(),
// body: instance.editor.exportFile(),
// sticky: $('#sticky').is(':checked'),
// userId: $('#postUser').val(),
// status: parseInt($('input[name=status]:checked').val())
// };
// // PostedAt
// var $postedAtDate = $('#postedAtDate');
// var $postedAtTime = $('#postedAtTime');
// var setPostedAt = false;
// var postedAt = new Date(); // default to current browser date and time
// var postedAtDate = $postedAtDate.datepicker('getDate');
// var postedAtTime = $postedAtTime.val();
// if ($postedAtDate.exists() && postedAtDate != "Invalid Date"){ // if custom date is set, use it
// postedAt = postedAtDate;
// setPostedAt = true;
// }
// if ($postedAtTime.exists() && postedAtTime.split(':').length==2){ // if custom time is set, use it
// var hours = postedAtTime.split(':')[0];
// var minutes = postedAtTime.split(':')[1];
// postedAt = moment(postedAt).hour(hours).minute(minutes).toDate();
// setPostedAt = true;
// }
// if(setPostedAt) // if either custom date or time has been set, pass result to properties
// properties.postedAt = postedAt;
// // URL
// var url = $('#url').val();
// if(!!url){
// var cleanUrl = (url.substring(0, 7) == "http://" || url.substring(0, 8) == "https://") ? url : "http://"+url;
// properties.url = cleanUrl;
// }
// // ------------------------------ Callbacks ------------------------------ //
// // run all post submit client callbacks on properties object successively
// properties = postSubmitClientCallbacks.reduce(function(result, currentFunction) {
// return currentFunction(result);
// }, properties);
// // console.log(properties)
// // ------------------------------ Insert ------------------------------ //
// if (properties) {
// Meteor.call('post', properties, function(error, post) {
// if(error){
// throwError(error.reason);
// clearSeenErrors();
// $(e.target).removeClass('disabled');
// if(error.error == 603)
// Router.go('/posts/'+error.details);
// }else{
// trackEvent("new post", {'postId': post._id});
// if(post.status === STATUS_PENDING)
// throwError('Thanks, your post is awaiting approval.');
// Router.go('/posts/'+post._id);
// }
// });
// } else {
// $(e.target).removeClass('disabled');
// }
// },
// 'click .get-title-link': function(e){
// e.preventDefault();
// var url=$("#url").val();
// var $getTitleLink = $(".get-title-link");
// $getTitleLink.addClass("loading");
// if(url){
// $.get(url, function(response){
// if ((suggestedTitle=((/<title>(.*?)<\/title>/m).exec(response.responseText))) != null){
// $("#title").val(suggestedTitle[1]);
// }else{
// alert("Sorry, couldn't find a title...");
// }
// $getTitleLink.removeClass("loading");
// });
// }else{
// alert("Please fill in an URL first!");
// $getTitleLink.removeClass("loading");
// }
// }
});